package com.hook3.pianke.activity.base.radiouserbasepager.PrivateRadioViewpagerBase;

import android.app.Activity;
import android.view.View;

import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hook3.pianke.R;
import com.hook3.pianke.domain.RadioPlayerViewPagerInfo;

import org.xutils.image.ImageOptions;
import org.xutils.x;

import java.util.List;

/**
 * Created by HOME on 2015/12/11.
 */
public class PrivateRadioViewpager4 extends PrivateRadioViewpagerBasePager {

    RadioPlayerViewPagerInfo radioPlayerViewPagerInfo;
    public PrivateRadioViewpager4(Activity activity, RadioPlayerViewPagerInfo radioPlayerViewPagerInfo){
        super(activity);
        this.radioPlayerViewPagerInfo = radioPlayerViewPagerInfo;
    }

    TextView mHostName;
    TextView mRadioName;
    ImageView mHostImage;
    TextView mAuthorName;
    ImageView mAuthorImage;
    PrivateRadioDefineGridView gv;
    @Override
    public View initView() {
        View view = View.inflate(activity, R.layout.private_radio_viewpager4,null);

        mHostName = (TextView) view.findViewById(R.id.tv_private_radio_view_pager_host_name);
        mRadioName = (TextView) view.findViewById(R.id.tv_private_radio_view_pager_radio_name);
        mHostImage = (ImageView) view.findViewById(R.id.tv_private_radio_view_pager_host_image);
        mAuthorName = (TextView) view.findViewById(R.id.tv_private_radio_view_pager_original_author_name);
        mAuthorImage = (ImageView) view.findViewById(R.id.iv_private_radio_view_pager_original_author_image);
        gv = (PrivateRadioDefineGridView) view.findViewById(R.id.gv_private_radio_view_pager_grid_view);

        return view;
    }

    List<RadioPlayerViewPagerInfo.DataEntity.MoretingEntity> moreting;
    public void initData(){
        RadioPlayerViewPagerInfo.DataEntity data = radioPlayerViewPagerInfo.getData();
        mHostName.setText(data.getAuthorinfo().getUname());

        ImageOptions imageOptions = new ImageOptions.Builder().build();
        x.image().bind(mHostImage, data.getAuthorinfo().getIcon(), imageOptions);

        mAuthorName.setText(data.getAuthorinfo().getUname());
        x.image().bind(mAuthorImage, data.getAuthorinfo().getIcon(), imageOptions);

        mRadioName.setText(data.getRadioname());

        moreting = data.getMoreting();

        gv.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return moreting.size();
            }

            @Override
            public String getItem(int position) {
                return moreting.get(position).getTitle();
            }

            @Override
            public long getItemId(int position) {
                return position;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                convertView = View.inflate(activity, R.layout.item_view_pager4, null);
                TextView sixName = (TextView) convertView.findViewById(R.id.tv_private_radio_view_pager4_sixName);
                sixName.setText(moreting.get(position).getTitle());

                return convertView;
            }
        });

    }
}
